﻿using System;
using Alex.HydroDynLib.Measures;
using Alex.HydroDynLib.Enums;

namespace Alex.HydroDynLib.UndimMeasure
{
	public class ReynoldsNumber : UMeasureBase
    {
        #region Constructors

        public ReynoldsNumber()
        {
        }

        public ReynoldsNumber(double velocity, double length)
        {
            this.velocity.Value = velocity;
            this.length.Value = length;
            value = calcValue();
        }

        public ReynoldsNumber(ReynoldsNumber re)
        {
            velocity = re.velocity;
            length = re.length;
            value = calcValue();
        }

        #endregion

        public override double Velocity
        {
            set
            {
                if (value >= 0)
                {
                    velocity.Value = value;
                    this.value = calcValue();
                    return;
                }
                throw new Exception("The value must not be below than zero");
            }
        }

        public override double Length
        {
            set
            {
                if (value > 0)
                {
                    length.Value = value;
                    this.value = calcValue();
                    return;
                }
                throw new Exception("The value must be greater than zero");
            }
        }

        public override double Value
        {
        	get { return value; }
            set { return; }
        }

        public override string Measure
        {
            get { return "Undimentional"; }
        }

        public override string ToString()
        {
            return Value.ToString();
        }

        private double calcValue()
        {
            return velocity.Value * length.Value / Constants.nu;
        }
    }
}
